package com.zking.myservlet.view;

import com.zking.dao.ViewDao;
import com.zking.util.RedirectMsg;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/manage/ViewUpdate")
public class ViewUpdate extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //处理请求的编码，解决中文乱码
        request.setCharacterEncoding("utf-8");
        //处理响应的编码 ，解决中文乱码
        response.setContentType("text/html;charset=utf-8");
        System.out.println("ViewUpdate===进来");
        //接收数据
        String review=request.getParameter("review");
        Integer uuid=Integer.parseInt(request.getParameter("uuid"));
        System.out.println(review);

        ViewDao.updateViews(review, uuid);

        request.setAttribute("msg", RedirectMsg.reviewSuccess);
        request.setAttribute("pageName", RedirectMsg.viewListPageName);
        request.setAttribute("url", RedirectMsg.viewListOfBackUrl);
        request.getRequestDispatcher("redirect.jsp").forward(request, response);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}